package com.yeyks.hotel.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.hotel.dal.dao.HotelCommissionBillMapper;
import com.yeyks.hotel.dal.domain.HotelCommissionBill;
import com.yeyks.hotel.dto.HotelCommissionBillListDTO;
import com.yeyks.hotel.param.HotelCommissionBillListParam;
import com.yeyks.hotel.service.HotelCommissionBillService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * <p>
 * 酒店佣金明细表 服务实现类
 * </p>
 *
 * @author yun
 * @since 2019-06-25
 */
@Service
public class HotelCommissionBillServiceImpl extends ServiceImpl<HotelCommissionBillMapper, HotelCommissionBill> implements HotelCommissionBillService {

    @Override
    public AjaxResponseBody list(HotelCommissionBillListParam hotelCommissionBillListParam) {
        PageHelper.startPage(hotelCommissionBillListParam.getPageNum(), hotelCommissionBillListParam.getPageSize());
        List<HotelCommissionBillListDTO> hotelCommissionBillListDTOS = baseMapper.selectForHotelPageV2(hotelCommissionBillListParam);
        PageInfo<HotelCommissionBillListDTO> page = new PageInfo<>(hotelCommissionBillListDTOS);
        return AjaxResponseBody.success(page);
    }

    @Override
    public Integer insert(HotelCommissionBill bill) {
        bill.setCreateTime(new Date());
        return baseMapper.insert(bill);
    }

}
